<template>
	<view>
		<!-- 轮播图 -->
		<view class="u-demo-area">
			<u-toast ref="uToast"></u-toast>
			<u-swiper @change1="change" :height="350" :list="list" :title="title" :effect3d="effect3d" :indicator-pos="indicatorPos"
			 :mode="mode" :interval="3000" @click="click1"></u-swiper>
		</view>
		<!-- 宫格布局 -->
		<view class="u-demo-area">
			<u-toast ref="uToast"></u-toast>
			<u-grid :column="3" @click="click" v-if="!isSwiper" :border="border">
				<u-grid-item :index="0">
					<image src="../../static/bj.png" style="width: 50px;height: 50px;">
						<view class="grid-text">报警</view>
				</u-grid-item>
				<u-grid-item :index="1">
					<image src="../../static/yjbj.png" style="width: 50px;height: 50px;">
						<view class="grid-text">一键报警</view>
				</u-grid-item>
				<u-grid-item :index="2">
					<image src="../../static/bjls.png" style="width: 50px;height: 50px;">
						<view class="grid-text">报警历史</view>
				</u-grid-item>
				<u-grid-item :index="3">
					<image src="../../static/aqks.png" style="width: 50px;height: 50px;">
						<view class="grid-text">安全考试</view>
				</u-grid-item>
				<u-grid-item :index="4">
					<image src="../../static/grzx.png" style="width: 50px;height: 50px;">
						<view class="grid-text">个人中心</view>
				</u-grid-item>
				<u-grid-item :index="5">
					<image src="../../static/gaaq.png" style="width: 50px;height: 50px;">
						<view class="grid-text">公安安全</view>
				</u-grid-item>
			</u-grid>

		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				recommend: [],
				/* 轮播图 */
				list: [],
				title: false,
				mode: 'round',
				indicatorPos: 'bottomCenter',
				effect3d: true,
				/* 宫格布局 */
				list2: ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'],
				isSwiper: false,
				border: true,
				col: 4,
				/* 查看更多 */
				name: [{
					title: '最新推荐'
				}, {
					title: '热度推荐'
				}, {
					title: '喜好专区'
				}, {
					title: '共享图书'
				}, ],
				bold: true,
				right: false,
				color: this.$u.color['mainColor'],
				showLine: true,
				/* 数据 */
				list1: [{
						name: '待付款'
					},
					{
						name: '待发货'
					},
					{
						name: '待收货'
					},
					{
						name: '待评价',
						count: 12
					}
				],
				news: [],
				hot: [],
				love: [],
				share: [],
				current: 0,
				swiperCurrent: 0,
				tabsHeight: 0,
				dx: 0,
				loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
			}
		},
		onLoad() {
			this.$u.api.selectrecommend({
				recommendPage: "0"
			}).then(res => {
				this.list = res.rows;
				console.log(this.list);
			})
		},
		computed: {},
		onShow() {
			//获取维修任务列表
			// this.$u.get('http://192.168.1.178:8080/mobile/repairmisson')
			// 	.then(res => {
			// 		this.repairwork = res.data.length;
			// 	}).catch(res => {
			// 		console.log("获取失败");
			// 	})
		},
		created() {
			console.log(getApp().globalData.userNumber)
			
			/* this.$u.post('http://192.168.1.160:8080/system/book/advertisement', {}).then(res => {
				for (var i = 0; i < list.length; i++) {
					this.list[i].image = res.rows[i].picture;
				}
				//this.list = res.rows;
				console.log(this.list);
			}).catch(res => {}); */


		},
		methods: {
			openPage(path) {
				this.$u.route({
					url: path
				})
			},
			change1(index) {
				// console.log(index);
			},
			click1() {
				// console.log(index);
			},
			/* 宫格布局 */
			click(index) {
				switch (index) {
					case 0:
						uni.reLaunch({
							url: '/pages/callpolice/index'
						})
						break;
					case 1:
						wx.makePhoneCall({
							phoneNumber: '18367430110' // 仅为示例，并非真实的电话号码
						})
						break;
					case 2:
						uni.navigateTo({
							url: '/pages/callpolice/history'
						})
						break;
					case 3:
						uni.navigateTo({
							url: '/pages/examination/index'
						})
						break;
					case 4:
						uni.reLaunch({
							url: '/pages/center/index'
						})
						break;
					case 5:
						uni.reLaunch({
							url: '/pages/propaganda/index'
						})
						break;
				}
			},
			// 针对单个grid-item的事件
			itemClick(index) {
				// console.log(index);
			},


			/* 跳转 */
			/* gobook(num) {
				this.$u.route({
					url: '/pages/bookcase/book/book_detail',
					params: {'bookNumber':num}
				})
			} */
		}
	}
</script>

<style scoped lang="scss">
	.item {
		margin: 30rpx 0;
	}

	.grid-text {
		font-size: 28rpx;
		margin-top: 4rpx;
		color: $u-type-info;
	}

	/* 数据 */
	.order {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;

		.item {
			display: flex;
			margin: 20rpx 0 0;

			.left {
				margin-right: 20rpx;

				image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}
			}

			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}

				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}

				.delivery-time {
					color: #e5d001;
					font-size: 24rpx;
				}
			}

			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;

				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}

				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}

		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;

			.total-price {
				font-size: 32rpx;
			}
		}

		.bottom {
			display: flex;
			margin-top: 40rpx;
			padding: 0 10rpx;
			justify-content: space-between;
			align-items: center;

			.btn {
				line-height: 52rpx;
				width: 160rpx;
				border-radius: 26rpx;
				border: 2rpx solid $u-border-color;
				font-size: 26rpx;
				text-align: center;
				color: $u-type-info-dark;
			}

			.evaluate {
				color: $u-type-warning-dark;
				border-color: $u-type-warning-dark;
			}
		}
	}

	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;

		image {
			width: 164rpx;
			height: 164rpx;
			border-radius: 50%;
			margin-bottom: 20rpx;
		}

		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}

		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
		}
	}

	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}

	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}

	/* 数据 */
</style>
